<layout:sign/>
<body class="hold-transition register-page">
<div class="register-box">
    <div class="register-logo">
        <a href="#"><b>Admin</b>LTE</a>
    </div>

    <div class="register-box-body">
        <p class="login-box-msg">Register a new membership</p>
        <form>
            <div class="form-group has-feedback">
                <input type="email" id="email" readonly value="{{email}}" class="form-control">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" id="password" class="form-control" placeholder="Password">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input type="password" id="repeat" class="form-control" placeholder="Retype password">
                <span class="glyphicon glyphicon-log-in form-control-feedback"></span>
            </div>
            <div class="row">
                <!--                <div class="col-xs-8">-->
                <!--                    <div class="checkbox icheck">-->
                <!--                        <label>-->
                <!--                            <input type="checkbox"> I agree to the <a href="#">terms</a>-->
                <!--                        </label>-->
                <!--                    </div>-->
                <!--                </div>-->
                <!-- /.col -->
                <div class="col-xs-4">
                    <button type="button" id="submit" class="btn btn-primary btn-block btn-flat">Register</button>
                </div>
                <!-- /.col -->
            </div>
        </form>

        <!--        <div class="social-auth-links text-center">-->
        <!--            <p>- OR -</p>-->
        <!--            <a href="#" class="btn btn-block btn-social btn-facebook btn-flat"><i class="fa fa-facebook"></i> Sign up-->
        <!--                using-->
        <!--                Facebook</a>-->
        <!--            <a href="#" class="btn btn-block btn-social btn-google btn-flat"><i class="fa fa-google-plus"></i> Sign up-->
        <!--                using-->
        <!--                Google+</a>-->
        <!--        </div>-->
        <br>
        <a href="__PUBLIC__/admin/sign/in" class="text-center">I already have a membership</a>
    </div>
    <!-- /.form-box -->
</div>
<!-- /.register-box -->
<script>

    isea.ready(function () {
        var token = "{{token}}";
        var error = "{{error}}";
        var email = "{{email}}";
        if (error) {
            return isea.notify.show(error, true);
        } else {
            $("#submit").click(function () {
                var password = $("#password").val();
                var repeat = $("#repeat").val();
                if (!password) {
                    return isea.notify.show('请填写密码');
                }
                if (repeat !== password) {
                    return isea.notify.show('密码前后不一致');
                }
                $.get("__PUBLIC__/admin/sign/regetinemail", {
                    token: token,
                    email: email,
                    password: password
                }, function (data) {
                    if (data.status) {
                        alert(data.message);
                        if (data.redirect) location.href = data.redirect;
                    } else {
                        isea.notify.show(data.message);
                    }
                });
            });
        }
    });

</script>
</body>

